<template>
	<u-tabbar :value="value1" @change="tapFn" :fixed="true" :placeholder="false" activeColor="#d81e06"
		:safeAreaInsetBottom="true">
		<!-- <u-tabbar-item text="首页">
			<image class="u-page__item__slot-icon" slot="active-icon"
				src="https://cdn.uviewui.com/uview/common/bell-selected.png"></image>
			<image class="u-page__item__slot-icon" slot="inactive-icon"
				src="https://cdn.uviewui.com/uview/common/bell.png"></image>
		</u-tabbar-item> -->
		<u-tabbar-item v-for="(item) in list" :text="item.text" :icon="item.icon"
			></u-tabbar-item>
	</u-tabbar>
</template>

<script>
	export default ({
		data() {
			return {
				"list": [{
						"text": "首页",
						"pagePath": "/pages/index/index",
						"icon": "photo"
					},
					{
						"text": "专题",
						"pagePath": "/pages/topic/topic",
						"icon": "photo"
					},
					{
						"text": "分类",
						"pagePath": "/pages/category/category",
						"icon": "photo"
					},
					{
						"text": "购物车",
						"pagePath": "/pages/cart/cart",
						"icon": "play-right"
					},
					{
						"text": "我的",
						"pagePath": "/pages/user/user",
						"icon": "account"
					}
				]
			}
		},
		methods: {
			tapFn(e){
				if(this.list[e].pagePath==="/pages/cart/cart"){
									let token = uni.getStorageSync('token')
									if(!token){
										uni.showToast({
											title: "没有登录",
											icon: "error",
											duration:1500
										})
										setTimeout(()=>{
											uni.switchTab({
												url:this.list[4].pagePath
											})
										},1000)
										return
									}
				}
				uni.switchTab({
					url:this.list[e].pagePath
				})

			}
		},
		computed:{
			value1(){
				return this.$store.state.storeIndex
			}
		}
	})
</script>

<style>
	
</style>
